Currently, a coprocessor (coprocessor) is a chip and is mainly used to substitute for a central processing unit (CPU) to process a specific task. Because the coprocessor and the central processing unit have some differences in an instruction set, a program running on the coprocessor generally needs to be complied independently by using a compiler, and requires certain code adjustment. In the prior art, for codes of a certain application, labels are generally attached to the codes of the application, and the labels are used to distinguish which codes are executed by the CPU, and which codes are executed by the coprocessor. First, all codes of the application are compiled, which includes that codes executed by the CPU and codes executed by the coprocessor are compiled differently according to labels. After the codes are compiled, during running of a process of the application on the CPU, if the process runs to a compiled code that needs to be executed by the coprocessor, the CPU pauses the execution of the process of the application, sends, to the coprocessor, the compiled code that needs to be executed by the coprocessor, and offloads (offload) the code at the label to the coprocessor for execution.
As can be known from above, in the prior art, after compilation of the codes of the application is completed, which part of compiled codes are executed by the CPU and which compiled codes are executed by the coprocessor are definite, but any code cannot be sent to the coprocessor for execution according to a requirement. Consequently, actual usage of the coprocessor is low, and CPU load cannot be reduced properly.